QUIET		= @
CC			= gcc
MAKE		= make --no-print-directory
GLOBAL_OPTS	= -Wall  -Wshadow -Wextra -O3 -g
# Other useful flags: -DNDEBUG 

SNAME		:= $(shell uname)
ifeq ($(strip $(SNAME)),Linux)
LDFLAGS		=  -lrt
else
LDFLAGS		= 
endif

SRCL 	:= $(shell find . -type f -name "*.c" -print0 | xargs -0 )
SRCA	= $(subst ./,,$(SRCL))
OBJS	= $(subst .c,.o,$(SRCA))

APPS	= main test

all: $(OBJS) $(APPS)

%.o: %.c
	@echo "> Object $@ <"
	$(QUIET) test -d .deps || mkdir .deps;
	$(QUIET) $(CC) $(GLOBAL_OPTS) $< -MT $@ -MM -MP -MF .deps/$*.d
	$(QUIET) $(CC) $(GLOBAL_OPTS) -c -o $@ $<

%: %.o
	@echo "> Target $@ <"
	$(QUIET) $(CC) $(GLOBAL_OPTS) $^ $(LDFLAGS) -o $@

main: bpt.o bpt_extra.o main.o

test: bpt.o test.o


.PHONY: clean

clean:
	$(QUIET) rm -rf $(OBJS) $(APPS) *.dSYM .deps